import {
	dumpFunc
} from '@src/common/dump'
Component({
	/**
	 * 组件的属性列表
	 */

	properties: {
		modules: {
			type: Array,
			value: [],
		},
		login: {
			type: Boolean
		}
	},
	options: {
		multipleSlots: true,
		addGlobalClass: true
	},

	/**
	 * 组件的初始数据
	 */
	data: {
		pic: null,
		height: 0,
		modulesData: null,
	},
	lifetimes: {
		attached: function() {
			if (!this.data.modules.length > 0) {
				return
			};
			let modulesData = this.data.modules[0];
			this.data.modulesData = modulesData;
			let pic = modulesData.pic;
			this.setData({
				pic,
				modulesData
			});
			console.log("pic", this.data.pic)
		}
	},

	/**
	 * 组件的方法列表
	 */
	methods: {
		imageLoad: function(e) { //获取图片真实宽度
			let imgwidth = e.detail.width;
			let imgheight = e.detail.height;
			//宽高比
			let ratio = imgwidth / imgheight;
			//计算的高度值
			let viewHeight = 750 / ratio;
			this.setData({
				height: viewHeight
			})
		},
		dumpPage(e) {
			let {
				dump,
				biz
			} = this.data.modulesData;
			if (!this.data.login && dump.path != "pages/indexChooseCard/main") {
				this.triggerEvent('login');
				return;
			}
			dumpFunc(dump, biz)
		}
	}
})
